package com.guldan.jaina.provider;

import com.guldan.core.dubbo.client.ResponseDTO;
import com.guldan.core.search.Pagination;
import com.guldan.jaina.dto.feedback.FeedbackDTO;
import com.guldan.jaina.dto.feedback.FeedbackSearchDTO;
import com.guldan.jaina.manager.FeedbackManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Silas.
 * Date: 2017/2/22
 * Time: 12:11
 */
@Component
public class FeedbackProviderImpl implements IFeedbackProvider {

    @Autowired
    private FeedbackManager feedbackManager;

    @Override
    public ResponseDTO<FeedbackDTO> get(Integer id) {
        ResponseDTO<FeedbackDTO> responseDTO = new ResponseDTO<>();
        responseDTO.setData(feedbackManager.get(id));
        return responseDTO;
    }

    @Override
    public ResponseDTO<FeedbackDTO> save(FeedbackDTO dto) {
        ResponseDTO<FeedbackDTO> responseDTO = new ResponseDTO<>();
        responseDTO.setData(feedbackManager.save(dto));
        return responseDTO;
    }

    @Override
    public ResponseDTO<Boolean> delete(Integer id) {
        ResponseDTO<Boolean> responseDTO = new ResponseDTO<>();
        responseDTO.setData(feedbackManager.delete(id));
        return responseDTO;
    }

    @Override
    public ResponseDTO<Pagination<FeedbackDTO>> list(FeedbackSearchDTO searchDTO) {
        ResponseDTO<Pagination<FeedbackDTO>> responseDTO = new ResponseDTO<>();
        responseDTO.setData(feedbackManager.list(searchDTO));
        return responseDTO;
    }
}
